#include <algorithm>
#include "common.h"

using namespace std;

/**
 * All possible ways to walk through the board
 */
int DX[] = { -1, -1,  0,  0,  1,  1 };
int DY[] = { -1,  0, -1,  1,  0,  1 };
int DN = 6; // Count of ways

/**
 * Returns distance between two points
 */
int distance(int x1, int y1, int x2, int y2)
{
	if(x1 <= x2 && y1 <= y2)
	{
		return max(x2 - x1, y2 - y1);
	}
	else if(x1 > x2 && y1 <= y2)
	{
		return x1 - x2 + y2 - y1;
	}
	else if(x1 <= x2 && y1 > y2)
	{
		return x2 - x1 + y1 - y2;
	}
	else //if (x1 > x2 && y1 > y2)
	{
		return max(x1 - x2, y1 - y2);
	}
}

/**
 * Returns whether a point lies within a field of the specified radius
 */
bool inside(int x, int y, int field_radius)
{
	return (distance(x, y, field_radius, field_radius) <= field_radius);
}